The present invention relates to methods and apparatus for exchanging messages in a computer network. More particularly, the present invention relates to improved techniques for allocating memory in a server of a computer network to more efficiently service the communication needs of multiple network connections in the computer network.
Computers in a computer network oftentimes communicate with one another by exchanging messages. In a computer network architecture known as a client-server architecture, messages between two client computers are typically exchanged via a third computer known as a server computer. By way of example, FIG. 1 illustrates a typical computer network 200 representing, for example, a local area network (LAN). Computer network 200 typically includes two or more interconnected computers. In FIG. 1, computer network 200 includes computers 202, 204, 206, 208, and 210. Computer 202 may be designated a server for servicing the communication needs of its client computers 204, 206, 208, and 210. Each of client computers 204, 206, 208, and 210 may be coupled to server 202 via a network interface circuit 218 to allow the client computers to exchange messages via server 202.
Server 202 may also be coupled to other servers, e.g., server 212. Server 212 represents a server which may belong to another local area network and/or may be coupled to a larger computer network, e.g., the Internet 216. Via server 202 and 212, any of clients 204, 206, 208, and 210 may also communicate with a computer coupled to server 212, e.g., client computer 214 or a computer in the Internet 216. For example, client computer 204 may send a message to client computer 206 through server 202 along communication path 220. As a further example, client computer 214 may send a message to client computer 208 (through servers 212 and 202) via a communication path 222.
In servicing the communication needs of its client computers, server computer 202 has a fundamental limitation. Within server computer 202, there exists a finite memory resource. For example, although modem servers are typically endowed with a large amount of random access memory (RAM), this memory resource is not unlimited. This limited memory resource must be allocated among the multiple client computers, each of which needs a certain amount of memory buffer within server computer 202 to buffer the data it wishes to transmit to another client computer via server computer 202.
If too much buffer memory is allocated for each client, the finite memory space within server computer 202 can service only a few network connections, i.e., clients, at any given time. If a smaller amount of buffer memory is allocated for each client, a greater number of network connections may be served simultaneously. However, server computer 202 must frequently write the smaller buffer memory spaces to disk in order to satisfy the memory needs of each network connection. Writing to disk, which is a known technique for extending a small memory space to satisfy a larger memory requirement, is however slow. This is because disk-based memory has a slower access speed and is inherently slower in operation than semiconductor memory. Accordingly, performance may suffer as server computer 202 writes to disk often.
To further illustrate the foregoing, FIG. 2 shows a memory 300, representing the memory space within server computer 202. In the prior art, each network connection is allotted a fixed amount of buffer memory to service its data buffering needs within server computer 202. For discussion purposes, memory 300 is divided into nine buffer memory spaces 304, with each buffer memory space servicing a different network connection.
Data streams 308 and 307 represent the data streams associated with two different network connections, e.g., from the network connection between client 204 and server 206 of FIG. 1, and from the network connection between client 208 and server 214 respectively. As shown in FIG. 2, data stream 308 is allotted buffer memory space 304(a) while data stream 307 is allotted buffer memory space 304(b). If there are other network connections currently active, their data streams may be allotted other buffer memory spaces in memory 300, e.g., buffer memory spaces 304(c)-304(i).
If the size of the data stream is smaller than or equal to the size of the buffer memory space, that data stream can be buffered in its entirety within its allotted buffer memory space in memory 300, and there is no need to write to disk 310. This is illustrated in the case of data stream 307, wherein the actual data 307(a) is smaller than the allotted buffer memory space 304(b) and must, in some systems, be padded with data 307(b) to facilitate storage within buffer memory space 304(b).
If the data stream is larger than can be stored in its entirety within its allotted buffer memory space, however, it is typically divided in the prior art into multiple data portions. By way of example, data stream 308 is divided into multiple equal data portions 308(a), 308(b), 308(c), 308(d), and so on in FIG. 2. To facilitate data buffering within buffer memory space 304(a), the size of each data portions 308(a)-308(d) typically is slightly smaller than or equal to the size of buffer memory space 304(a).
For the larger data streams, each data portion of the data stream is, in a serial manner, first written to the buffer memory space allotted to that data stream, and then written to disk to allow the allotted buffer memory space to receive the next data portion. With reference to FIG. 2, for example, data portion 308(a) of data stream 308 would be written to buffer memory space 304(a) and then to disk 310 (via path 312) to enable buffer memory space 304(a) to receive subsequent data portions of data stream 308, e.g., data portions 308(b), 308(c), 308(d), and so on.
For ideal performance, each buffer memory space should be as large as possible. This is because the responsiveness of a network connection depends, in part, on the size of the buffer memory space allotted to it. As mentioned earlier, however, the buffer memory space allotted to each network connection cannot be infinite since the memory available within the server computer is a) of a finite size, and b) must be apportioned among many network connections. In the prior art, optimization typically involves balancing, among other issues, the size of the buffer memory space allotted to the network connections versus the number of network connections simultaneously served.
While the prior art data buffering scheme of FIG. 2 is workable, particularly when the size of the data portions (and corresponding buffer memory spaces) is carefully chosen, there are, however, disadvantages. The prior art requires that all data portions of a given data stream be equal in size. The prior art also statically assigns a buffer memory space to a data stream and requires this buffer memory space to service all the data buffering need of this network connection. Accordingly, the corresponding buffer memory space must at least equal or be larger in size than the size of the equal data portion in order to properly buffer it. It is discovered, however, that there is a fair amount of waste and inefficiency in the prior art's utilization of the server's memory space irrespective of the size of the buffer memory space chosen.
To illustrate, if the size of each buffer memory space 304 is small, a high number of writes may be needed for most messages, and connection responsiveness suffers. If the size of each buffer memory space 304 is large, only a few simultaneous connections may be served. Additionally, larger buffer memory spaces expose a greater portion of the data stream to risk of loss, e.g., from power failure, since more of the data stream is kept in volatile memory and few writes to the nonvolatile memory, e.g., disk, are performed.
Even if the size of each buffer memory space 304 is optimized for most messages (taking into account the tradeoff between responsiveness, data safety, and the desired number of simultaneous network connections), there is waste when the data stream happens to be much smaller than the allotted buffer memory space, which has been optimized for all data streams, large or small. This waste problem is particularly disadvantageous for certain type of data, such as electronic mails, wherein a significant percentage of the messages are fairly small and only a few messages are large but the buffer memory spaces in the server memory must be sized such that the larger messages do not unduly suffer in term of connection responsiveness.
In view of the foregoing, there are desired improved techniques for buffering data for multiple network connections within the memory of the server computer. The improved techniques preferably maximize the number of network connections served in the limited memory of the server computer while minimizing the delay associated with writing to disks, thereby improving the responsiveness of the network connections.